
import {Pipe, PipeTransform} from '@angular/core';
 @Pipe({ name: 'Timestamp_pipe' })
export class Timestamp_pipe implements PipeTransform {
  transform(value: string,hasSec:boolean=false): string {
    if(!value) return value;
    if(typeof value !== 'number') {
      throw new Error('Invalid pipe argument for WelcomePipe');
    }

     var d = new Date( parseInt(value)*1000 );  
      var dformat = [ d.getFullYear(), d.getMonth() + 1, d.getDate() ].join('-')   
     if (hasSec)
        dformat+= ' ' + [ d.getHours(), d.getMinutes(), d.getSeconds() ].join(':');  
    return dformat;  
    
  }
} 